home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
hity wydania
/
trueSpace 7.6
/
tS761B8Std.exe
/
{app}
/
Scripts
/
D3D
/
RsD3DWireRender.fx
< prev
next >
Wrap
Text File
|
2008-06-10
|
4KB
|
172 lines
//----------------------------------------------------------------------
//Wireframe-rendering
//
//Author - Michal Valient
//Copyright (C) 2004-2008 Caligari corporation
//
//----------------------------------------------------------------------
uniform float4x4 mToClip;
uniform float4 cColorMultiplier;
uniform float4 cColorModifier;
uniform float fOpacity;
uniform float fDepthBias = 1.0f / 65536.0f; //Set depth bias to the value that will work for 16bit z-buffers
#ifdef RsShaderHWSKINNING
#define SKIN_INDEX_SHIFT 0.001960784313725490196078431372549f
#define RTD3DMESH_MAXIMUM_BONE_COUNT 64
float4x3 RsD3DMaterialFromME_mSkinMatrices[RTD3DMESH_MAXIMUM_BONE_COUNT];
#endif //RsShaderHWSKINNING
struct VS_MATPOINT_IN {
float4 vPosition : POSITION; //position in object space
float4 cPointColor : COLOR; //point color
};
typedef struct {
float4 vPosition : POSITION; //position in object space
float4 cPointColor : COLOR; //point color
} VS_MATPOINT_OUT;
VS_MATPOINT_OUT VS_CMaterialPointRender( in VS_MATPOINT_IN input
#ifdef RsShaderHWSKINNING
, in float4 D3_vInputBlendIndices : BLENDINDICES
, in float4 D3_cInputBlendWeight : BLENDWEIGHT
#endif //RsShaderHWSKINNING
)
{
float4 local_vertex_position;
#ifdef RsShaderHWSKINNING
float3 tmp_position = 0;
//Get the blend weights
float4 blend_weights = (255.0f/127.0f)*D3_cInputBlendWeight - (128.0f / 127.0f);
float4 blend_indices = D3_vInputBlendIndices * 255.0f + SKIN_INDEX_SHIFT;
/// Skin it!
for (int bone_idx = 0; bone_idx<4; bone_idx++)
{
int matrix_idx = (int)blend_indices[bone_idx];
float weight = blend_weights[bone_idx];
float3 bone_position = weight*mul(input.vPosition, RsD3DMaterialFromME_mSkinMatrices[matrix_idx]);
tmp_position += bone_position;
}
local_vertex_position.xyz = tmp_position.xyz;
local_vertex_position.w = 1.0f;
#else
local_vertex_position = input.vPosition;
#endif //RsShaderHWSKINNING
VS_MATPOINT_OUT output;
output.vPosition = mul(local_vertex_position, mToClip); //vertex clip position
output.vPosition.z = ((output.vPosition.z/output.vPosition.w) - fDepthBias) * output.vPosition.w;
output.cPointColor = cColorMultiplier * input.cPointColor + cColorModifier;
output.cPointColor.a = fOpacity * input.cPointColor.a;
return output;
}
float4 PS_CMaterialPointRender(float4 cPointColor : COLOR) : COLOR
{
return cPointColor;
}
vertexshader VS_PointRenderer = compile vs_2_0 VS_CMaterialPointRender();
pixelshader PS_PointRenderer = compile ps_1_1 PS_CMaterialPointRender();
///Point rendering for PS capable hardware
technique T_PointRender_PS
{
pass P0
{
VertexShader = (VS_PointRenderer);
PixelShader = (PS_PointRenderer);
AlphaBlendEnable = true;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = false;
SpecularEnable = false;
ColorVertex = true;
CullMode = NONE;
}
}
technique T_PointRender_Plain_Cascade
{
pass P0
{
VertexShader = (VS_PointRenderer);
PixelShader = NULL;
AlphaBlendEnable = true;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = false;
Lighting = false;
ShadeMode = GOURAUD;
SpecularEnable = false;
ColorVertex = true;
// Set the stages.
ColorOp[0] = SELECTARG1;
ColorArg1[0] = DIFFUSE;
ColorOp[1] = DISABLE;
AlphaOp[0] = SELECTARG1;
AlphaArg1[0] = DIFFUSE;
AlphaOp[1] = DISABLE;
CullMode = NONE;
}
}
technique T_PointRender_Plain
{
pass P0
{
VertexShader = (VS_PointRenderer);
PixelShader = NULL;
AlphaBlendEnable = true;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;
ZEnable = true;
ZFunc = LESSEQUAL;
ZWriteEnable = false;
Lighting = false;
ShadeMode = GOURAUD;
SpecularEnable = false;
ColorVertex = true;
CullMode = NONE;
}
}